<template>
  <div class="app-container">
    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="离职人员姓名" prop="path">
        <el-input v-model="path" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button v-preventReClick type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
        <el-button v-preventReClick icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>


    <!-- 列表 -->
    <el-table v-loading="loading" :data="list" class="margin-top">
      <el-table-column label="离职人员姓名" :show-overflow-tooltip="true" align="center" min-width="200px" prop="nickname"/>
      <el-table-column label="离职人员所属组织" :show-overflow-tooltip="true" align="center" min-width="250px" prop="deptName"/>
      <el-table-column label="离职变更日期" align="center" prop="createTime" min-width="200px" >
                  <template slot-scope="scope">
                      <span >{{ parseTime(scope.row.createTime) }}</span>
                    </template>
                </el-table-column>
      <el-table-column label="状态" align="center" prop="size" min-width="120px">
                      <span >生效</span>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="100px">
        <template v-slot="scope">
          <el-button v-preventReClick size="mini" type="text" @click="handleView(scope.row)">查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>


    <el-dialog title="查看" :visible.sync="open" width="600px" append-to-body>
        <el-form label-width="0px">
            <el-row>
            <el-col :span="24">
                <el-form-item prop="mobile" >
                    <el-input
                        type="textarea"
                        class="margin-top"
                        :autosize="{ minRows: 3, maxRows: 5}"
                        :rows="3"
                        placeholder="离职原因为空"
                        show-word-limit
                        resize="none"
                        maxlength="100"
                        disabled
                        v-model="textarea">
                    </el-input>
                </el-form-item>
            </el-col>
            </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button v-preventReClick type="primary" @click="open=false">关 闭</el-button>
        </div>
    </el-dialog>
  </div>
</template>

<script>
import {getDepartStaff, getUserDepart} from "@/api/infra/file";
import {getAccessToken} from "@/utils/auth";
import ImagePreview from "@/components/ImagePreview";

export default {
  name: "InfraFile",
  components: {
    ImagePreview
  },
  data() {
    return {
      getFileUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/',
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 文件列表
      list: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
      },
      path:'',
      //查看弹出层
      open:false,
      textarea:''
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 执行查询
      getUserDepart(this.queryParams).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
        console.log(this.queryParams,'this.queryParams---')
      });
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    reset() {
      this.form = {
        content: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      getDepartStaff(this.path).then(response => {
        this.list = response.data;
        this.total = response.data.length;
        console.log(response.data,'response.data--')
        this.loading = false;
      });
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.path=''
      this.resetForm("queryForm");
      this.getList();
    },
    handleView(item){
        this.textarea=item.departInfo
        this.open = true;
    }
  }
};
</script>
